package de.baumann.browser.activitys.order

import android.annotation.SuppressLint
import android.app.Activity
import de.baumann.browser.R
import de.baumann.browser.api.net.vo.PayParam
import de.baumann.browser.base.BaseOdinActivity
import de.baumann.browser.iview.IOdinPayView
import de.baumann.browser.present.OdinPayPresenter
import de.baumann.browser.views.dialog.PayPasswordDialog
import kotlinx.android.synthetic.main.activity_odin_pay.*
import kotlinx.android.synthetic.main.include_tool_bar.*

/**
 * @author：
 * @date：2018/12/17
 * @discription: odin 支付
 * <p>
 **/
@Deprecated("功能已删除")
class OdinPayActivity : BaseOdinActivity<IOdinPayView, OdinPayPresenter<IOdinPayView>>(), IOdinPayView, PayPasswordDialog.InputPayPasswordCallBack {

    private lateinit var payPasswordDialog: PayPasswordDialog

    override fun getTitleText(): String {
        return getString(R.string.odin_pay)
    }

    override fun getLayout(): Int {
        return R.layout.activity_odin_pay
    }

    override fun initView() {
        initToolbar(commToolBar,commTitle)
        btnOdinPay.setOnClickListener {
            payPasswordDialog = PayPasswordDialog(mContext)
            payPasswordDialog.inputPayPasswordCallBack = this@OdinPayActivity
            payPasswordDialog.show()
        }
    }

    override fun createPresenter(): OdinPayPresenter<IOdinPayView> {
        return OdinPayPresenter()
    }

    override fun createView(): IOdinPayView {
        return this
    }

    @SuppressLint("SetTextI18n")
    override fun initData() {
        tvOdinPayOrderId.text = getPayId()
        tvOdinPayAmount.text = "ODIN ${intent.getStringExtra("amount")}"
    }

    override fun getPayId(): String {
        return intent.getStringExtra("trandeNo")
    }

    override fun paySuccess() {
        payPasswordDialog.dismiss()
        showShortToast(getString(R.string.payment_completed))
        setResult(Activity.RESULT_OK)
        finish()
    }

    override fun inputedPassword(password: String) {
        presenter.odinPay(password)
    }

    override fun wxPay(payParam: PayParam?) {

    }
}
